package view;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

import controller.Controller;

import model.Oscilloscope;

/**
 * Oscilloscope megjelenítéséért felelős osztály
 * JPanel és MouseListener leszármazás és implementálás a kattinthatóságért
 * @author radioactivebee
 *
 */
public class OscilloscopeView extends JPanel implements Paintable, MouseListener, ModelProvider {

	private static final long serialVersionUID = 1L;
	private int x;
	private int y;
	private Oscilloscope scope;
	public InputView inputView;
	
	public OscilloscopeView(int x, int y, Oscilloscope scope) {
		super();
		this.x = x;
		this.y = y;
		this.scope = scope;
		inputView = new InputView(x, y+25, scope.getInput(), scope);
		setBounds(this.x, this.y, 70, 50);
		addMouseListener(this);
	}
	
	@Override
	public void mouseClicked(MouseEvent e){
		if(Controller.verbose){
			System.out.println("scopeview mouse listener invoked");		
		}
		Controller.getInstance().scopeClicked(this);
		Controller.getInstance().blockClicked(this);
	}

	@Override
	public void paint(Graphics g) {
		Image img = new ImageIcon("img/scope.png").getImage();
		g.drawImage(img, x, y, null);
		inputView.paint(g);
		
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public Oscilloscope getModel(){
		return scope;
	}
	
	@Override
	public void mouseEntered(MouseEvent arg0) {
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
	}

	@Override
	public void mousePressed(MouseEvent arg0) {	
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
	}
}
